package com.mkuspis.moviebrowser.activities;

import android.os.Bundle;
import android.widget.TextView;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.mkuspis.moviebrowser.R;

/**
 * Activity with info about application.
 */
public class InfoActivity extends SherlockActivity {

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info_layout);

        initializeActionBar();
        initializeView();
    }

    private void initializeActionBar() {
        final ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }

    @Override
    public boolean onOptionsItemSelected(final MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    private void initializeView() {
        final TextView appNameTitle = (TextView) findViewById(R.id.appNameTitle);
        final TextView versionTitle = (TextView) findViewById(R.id.appVersionTitle);
        final TextView authorsTitle = (TextView) findViewById(R.id.authorsTitle);
        final TextView appName = (TextView) findViewById(R.id.appName);
        final TextView version = (TextView) findViewById(R.id.appVersion);
        final TextView authors = (TextView) findViewById(R.id.authors);

        appNameTitle.setText(R.string.app_name_title);
        versionTitle.setText(R.string.version_title);
        authorsTitle.setText(R.string.authors_title);
        appName.setText(R.string.app);
        version.setText(R.string.version);
        authors.setText(R.string.authors);
    }
}